package cn04;

import java.util.ArrayList;
import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        ArrayList<car> array = new ArrayList<>();

        car(array);
        car(array);
        car(array);

        for (int i = 0; i < array.size(); i++) {
            car c = array.get(i);
            System.out.println(c.getName()+","+c.getPrice()+","+c.getColor());
        }

    }

    public static void car(ArrayList<car> array) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入汽车名字");
            String name = sc.nextLine();
            System.out.println("请输入汽车价钱");
            String price = sc.nextLine();
            System.out.println("请输入汽车的颜色");
            String color = sc.nextLine();

           car c= new car();
           c.setName(name);
           c.setPrice(price);
           c.setColor(color);

           array.add(c);
    }
}